package jwr;

import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JPanel;

public class KeyAction extends JPanel implements KeyListener{
	private int x = 100;
	private int y = 100;
	private char keyChar = 'A';
	public KeyAction() {
		addKeyListener(this);
	}
	@Override
	public void keyTyped(KeyEvent e) {	}
	@Override
	public void keyPressed(KeyEvent e) {
		keyChar = e.getKeyChar();
		repaint();
	}
	@Override
	public void keyReleased(KeyEvent e) {	}
	protected void paintComponent(Graphics g){
		super.paintComponent(g);
		g.setFont(new Font("TimesRoman", Font.PLAIN, 24));
		g.drawString(String.valueOf(keyChar), x, y);
	}
}
